'use strict';

module.exports = app => {
  class Controller extends app.Controller {
    async establish() {
      const message = this.ctx.args[0];
      const state = await this.service.ready.found(message);
      await this.ctx.socket.emit('goback', state);
    }

    async join() {
      const message = this.ctx.args[0];
      const state = await this.service.ready.player(message);
      await this.ctx.socket.emit('goback', state);
    }

    async leave() {
      const arg = this.ctx.args[0];
      await this.service.ready.leave(arg);
    }
  }

  return Controller;
};
